package ar.edu.unicen.pladema.resources;

import java.io.InputStream;
import java.net.URL;

import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;

public class JarResourse {
	private static JarResourse instance = null;
	private JarResourse() {}
	public static JarResourse getInstance() {
		if (instance == null) {
			instance = new JarResourse();
		}
		return instance;
	}
	
	public InputStream getResourceStream(String path) {
		System.out.println("JarResourse.getResourceStream:" + path);
		ClassLoader classLoader = getClass().getClassLoader();
		return classLoader.getResourceAsStream(path);
	}
	public URL getResourceURL(String path) {
		ClassLoader classLoader = getClass().getClassLoader();
		return classLoader.getResource(path);
	}
	public Image getResourceImage(Display display, String img) {
		InputStream is = JarResourse.getInstance().getResourceStream("img/" + img + ".png");
		Image image = new Image(display, is);
		return image;
	}
	public static void main(final String [] args) {
	}
}
